//Page Object
Page({
  data: {
    
  },
  //options(Object)
  onLoad: function(options){
    var tath = this;   
    var buy_id = options.buy_id;
    tath.setData({
      buy_id:buy_id
    })
    //查看购买记录详情
    getApp().request({
      url: getApp().api.cardshop.buy_card_details,
      data: {
        buy_id: buy_id
      },
      success: function (t) {
        console.log(t, '购买记录详情');
        if (t.code == 1) {
          console.log(t.msg);
        } else {
          tath.setData({
            details: t.data,
          });
        }
      },
      complete: function () { }
    });


  },
  onReady: function(){
    
  },
  onShow: function(){
    
  },
  onHide: function(){

  },
  onUnload: function(){

  },
  onPullDownRefresh: function(){

  },
  onReachBottom: function(){

  },
  onShareAppMessage: function(t){
    let that = this
    // var article_id = wx.getStorageSync('current_article_id');
    var path = '/pages/card_voucher/share/share?article_id=0&buy_id=' + that.data.buy_id;
    return {
      title:"分享给你",
      path: path,
      success:res=>{
        console.log(res)
        console.log(path)
        if (res.errMsg =="shareAppMessage:ok"){
          wx.showModal({            
            content: '请提醒好友领取礼品卡',
            success: function(res) {
                wx.redirectTo({
                  url: '/pages/card_voucher/index'
                })              
            }
          })
        }
      }
    }
    console.log(e)
  },
  onPageScroll: function(){

  },
  //item(index,pagePath,text)
  onTabItemTap:function(item){

  }
});